Code blocks can be
evaluated1 and the results placed in the Org-mode
buffer. By default, evaluation is only turned on for
emacs-lisp code blocks, however support exists for
evaluating blocks in many languages. See Languages for a list of supported
languages. See Structure
of code blocks for information on the syntax used to define a
code block.
There are a number of ways to
evaluate code blocks. The simplest is to press C-c C-c
or C-c C-v e with the point on a code block2.
This will call the org-babel-execute-src-block
function to evaluate the block and insert its results into the
Org-mode buffer.
It is also possible to evaluate named code blocks from
anywhere in an Org-mode buffer or an Org-mode table.
#+call (or synonymously #+function or
#+lob) lines can be used to remotely execute code
blocks located in the current Org-mode buffer or in the
“Library of Babel” (see Library of Babel).
These lines use the following syntax.
#+call: <name>(<arguments>) <header arguments>
#+function: <name>(<arguments>) <header arguments>
#+lob: <name>(<arguments>) <header arguments>
<name><arguments><header arguments>[1] Whenever code is evaluated there is a potential for that code to do harm. Org-mode provides a number of safeguards to ensure that it only evaluates code with explicit confirmation from the user. For information on these safeguards (and on how to disable them) see Code evaluation security.
[2] The
org-babel-no-eval-on-ctrl-c-ctrl-c variable can be
used to remove code evaluation from the C-c C-c key
binding.